package com.zlcode.cook.controller;

import com.zlcode.api.WaiterApi;
import com.zlcode.model.WaiterInfo;
import jakarta.websocket.server.PathParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/cook")
public class CookController {

    @Autowired
    private WaiterApi waiterApi;

    @RequestMapping("/ok")
    public String ok(@PathParam("content")String content, String username) {
        log.info("收到过滤器添加的参数:" + username);
        String resp = waiterApi.up(content);
        return "调用成功, 已收到 waiter 的响应: " + resp;
    }

    @RequestMapping("/get")
    public String get(@RequestParam("name")String name) {
        WaiterInfo waiterInfo = waiterApi.getInfo(name);
        return "调用成功, 已收到 waiter 的响应: " + waiterInfo;
    }
}
